package com.jk.controller;

import com.jk.bean.Article;
import com.jk.bean.BiaoTi;
import com.jk.bean.History;
import com.jk.bean.Type;
import com.jk.service.HistoryService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("his")
public class HistoryController {
    @Resource
    private HistoryService historyService;

    @ResponseBody
    @RequestMapping("getHistory")
    public List<History> getHistory(){
        return historyService.getHistory();
    }

    @ResponseBody
    @RequestMapping("getPage")
    public List<Type>getPage(){
        return historyService.getPage();
    }

    @RequestMapping("toUrl")
    public String toUrl(String biaoti, Model mo){


        List<BiaoTi> kg=historyService.queryBiaoti(biaoti);

        for (BiaoTi biaoTi : kg) {
            //=====作者
            mo.addAttribute("authorName",biaoTi.getName());
            //===点击量
            mo.addAttribute("dj", biaoTi.getDj());
            //===关注人气
            mo.addAttribute("gz", biaoTi.getGuanzhu());
            //===图片
            mo.addAttribute("img",biaoTi.getImg());
        }
        mo.addAttribute("bt", biaoti);

        return "author";
    }

    @RequestMapping("toString")
    public String toString(String biaoti, Model mo){
        List<BiaoTi> kg=historyService.queryBiaoti(biaoti);

        for (BiaoTi biaoTi : kg) {
            //=====作者
            mo.addAttribute("authorName",biaoTi.getName());
            //===点击量
            mo.addAttribute("dj", biaoTi.getBkcount());
            //===关注人气
            mo.addAttribute("gz", biaoTi.getGuanzhu());
            //===图片
            mo.addAttribute("img",biaoTi.getImg());
        }
            mo.addAttribute("bt", biaoti);

        return "information";
    }

    @ResponseBody
    @RequestMapping("getOne")
    public List<BiaoTi> getOne(String id){

        return historyService.getOne(id);
    }

    @ResponseBody
    @RequestMapping("getTwo")
    public List<BiaoTi> getTwo(String id){

        return historyService.getOne(id);
    }

    @ResponseBody
    @RequestMapping("getThree")
    public List<BiaoTi> getThree(String id){

        return historyService.getOne(id);
    }

    @ResponseBody
    @RequestMapping("getFour")
    public List<BiaoTi> getFour(String id){

        return historyService.getOne(id);
    }

    @ResponseBody
    @RequestMapping("getFive")
    public List<BiaoTi> getFive(String id){

        return historyService.getOne(id);
    }

    @ResponseBody
    @RequestMapping("getSix")
    public List<BiaoTi> getSix(String id){

        return historyService.getOne(id);
    }

    @ResponseBody
    @RequestMapping("getBoWen")
    public List<BiaoTi> getBoWen(){
        return historyService.getBoWen();
    }

    @ResponseBody
    @RequestMapping("getBoZhu")
    public List<BiaoTi> getBoZhu(){
        return  historyService.getBoZhu();
    }


    @ResponseBody
    @RequestMapping("getText")
    public List<Article> getText(){
        return   historyService.getText();
    }



}
